//package com.reger.test;
//
//import java.util.Arrays;
//import java.util.Collection;
//import java.util.Collections;
//import java.util.function.Function;
//import java.util.function.Predicate;
//import java.util.stream.Collectors;
//
//import com.google.common.collect.Lists;
//import com.google.common.collect.Range;
//
//import io.shardingjdbc.core.api.algorithm.sharding.ListShardingValue;
//import io.shardingjdbc.core.api.algorithm.sharding.PreciseShardingValue;
//import io.shardingjdbc.core.api.algorithm.sharding.RangeShardingValue;
//import io.shardingjdbc.core.api.algorithm.sharding.ShardingValue;
//import io.shardingjdbc.core.api.algorithm.sharding.hint.HintShardingAlgorithm;
//
//public class HintShardingAlgorithmImpl implements HintShardingAlgorithm {
//	 
//	@SuppressWarnings({ "rawtypes", "unchecked" })
//	@Override
//	public Collection<String> doSharding(final Collection<String> availableTargetNames, ShardingValue shardingValue) {
//		if(shardingValue instanceof ListShardingValue) {
//			ListShardingValue<?> sharding =(ListShardingValue)shardingValue;
//			if(sharding.getValues().contains(-1)) {
//				return availableTargetNames;
//			}
//			return sharding.getValues().stream().map(new Function<Object, String>() {
//
//				@Override
//				public String apply(Object s) {
//					if(s==null) {
//						return null;
//					}
//					if(s instanceof Integer) {
//						return Lists.newArrayList(availableTargetNames).get((Integer) s);
//					}
//					 return String.valueOf(s);
//				 }
//			}).collect(Collectors.<String>toList());
//		}else if(shardingValue instanceof PreciseShardingValue) {
//			Object s=((PreciseShardingValue)shardingValue).getValue();
//			if(s==null) {
//				return null;
//			}
//			if(s instanceof Integer) {
//				return Arrays.asList(Lists.newArrayList(availableTargetNames).get((Integer) s));
//			}
//			 return  Arrays.asList(String.valueOf(s));
//		}else if(shardingValue instanceof RangeShardingValue) {
//			final Range<String> vr = ((RangeShardingValue)shardingValue).getValueRange();
//			availableTargetNames.removeIf(new Predicate<String>() {
//				@Override
//				public boolean test(String t) {
//					return vr.contains(t);
//				}
//			});
//			return  availableTargetNames ;
//		}
//		return null;
//	}
//
//}
